# Importing Data
NEWZELAND<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Aluminium/Aluminium.xlsx",sheet = "Sheet1", range = "X1:X229")

# Checking the Imported Data
View(NEWZELAND)
# Creating Time Series Data
NEWZELAND_ts <- ts(NEWZELAND, start=c(1998,1), end=c(2016,12), frequency=12)
# Viewing and Checking the Created Time Series Data
NEWZELAND_ts
sum(is.na(NEWZELAND_ts))
library(forecast)
NEWZELAND_ts <- tsclean(NEWZELAND_ts)
NEWZELAND_ts

# Identification: Plotting the Time Series Data
plot(NEWZELAND_ts)

# Estimating the appropriate model
NEWZELAND_ts_model <- auto.arima(NEWZELAND_ts)
NEWZELAND_ts_model

# Forecasting
options(max.print=1000000)
NEWZELAND_ts_forecast <- forecast (NEWZELAND_ts_model, level=c(95), h=288)
plot(NEWZELAND_ts_forecast)
NEWZELAND_ts_forecast             

# Exporting
write.table(NEWZELAND_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Aluminium/NEWZELAND_TSA.csv", sep=",")
